home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / xv_pc16a.zip / TILE.PAS < prev    next >
Pascal/Delphi Source File  |  1994-04-20  |  2KB  |  115 lines

  1. PROGRAM Tile;
  2. {
  3. XView-PC demonstration: Non-usual window manipulation example
  4. By Antonio Carlos Moreirao de Queiroz - acmq@coe.ufrj.br
  5. }
  6.  
  7. USES Crt,Graph,Xview;
  8.  
  9. CONST max=49;
  10.  
  11. VAR
  12.   window,but:ARRAY[1..max] OF Xv_opaque;
  13.   control,Number,bok,bQuit: Xv_opaque;
  14.   i:INTEGER;
  15.  
  16. {$F+}
  17.  
  18. PROCEDURE InitTile(obj:Xv_opaque);
  19. BEGIN
  20.   open_window(control)
  21. END;
  22.  
  23. PROCEDURE DoTile(obj:Xv_opaque);
  24. VAR
  25.   n,kx,ky,nx,ny:INTEGER;
  26. BEGIN
  27.   close_window(control);
  28.   n:=1;
  29.   WHILE active_w^.under<>active_w DO BEGIN
  30.     Inc(n);
  31.     close_window(active_w)
  32.   END;
  33.   close_window(active_w);
  34.   xv_end:=FALSE;
  35.   nx:=Round(Sqrt(n)+0.4999);
  36.   WHILE (1.0*(n div nx) <> 1.0*n/nx) DO Inc(nx);
  37.   ny:=n div nx;
  38.   kx:=(GetMaxX+1) div nx;
  39.   ky:=(GetMaxY+1) div ny;
  40.   FOR i:=1 TO n DO BEGIN
  41.     window[i]^.dx:=kx-1;
  42.     window[i]^.dy:=ky-1;
  43.     window[i]^.y:=((i-1) div nx)*ky;
  44.     window[i]^.x:=((i-1) mod nx)*kx;
  45.     open_window(window[i])
  46.   END
  47. END;
  48.  
  49. PROCEDURE LimitNumber(obj:Xv_opaque);
  50. BEGIN
  51.   WHILE active_w^.under<>active_w DO close_window(active_w);
  52.   close_window(active_w);
  53.   xv_end:=FALSE;
  54.   FOR i:=1 TO Number^.panel_int DO open_window(window[i])
  55. END;
  56.  
  57. PROCEDURE Quit(obj:Xv_opaque);
  58. BEGIN
  59.   xv_end:=TRUE
  60. END;
  61.  
  62. {$F-}
  63.  
  64. BEGIN
  65.   xv_init(0,0);
  66.   FOR i:=1 TO max DO BEGIN
  67.     window[i]:=xv_create(frame);
  68.     WITH window[i]^ DO BEGIN
  69.       x:=Random(GetMaxX-200);
  70.       y:=Random(GetMaxX-200);
  71.       dx:=200;
  72.       dy:=200;
  73.       dxmin:=27;
  74.       dymin:=27;
  75.       Str(i,window[i]^.xv_label)
  76.     END;
  77.     but[i]:=xv_create(button);
  78.     WITH but[i]^ DO BEGIN
  79.       xv_label:=' ';
  80.       notify_handler:=InitTile
  81.     END
  82.   END;
  83.   control:=xv_create(frame);
  84.   WITH control^ DO BEGIN
  85.     xv_label:='Control';
  86.     dx:=150; dymin:=70; dy:=70;
  87.   END;
  88.   Number:=xv_create(textfield);
  89.   WITH Number^ DO BEGIN
  90.     field_type:=int_field;
  91.     min_value:=1;
  92.     max_value:=max;
  93.     panel_int:=9;
  94.     value_length:=5;
  95.     xv_label:='Windows';
  96.     notify_handler:=LimitNumber;
  97.   END;
  98.   bok:=xv_create(button);
  99.   WITH bok^ DO BEGIN
  100.     xv_label:='"Tile"';
  101.     y:=15;
  102.     notify_handler:=DoTile;
  103.     owner^.mouse_obj:=bok;
  104.   END;
  105.   bQuit:=xv_create(button);
  106.   WITH bQuit^ DO BEGIN
  107.     xv_label:='Quit';
  108.     y:=30;
  109.     notify_handler:=Quit
  110.   END;
  111.   FOR i:=1 TO 5 DO open_window(window[i]);
  112.   xv_main_loop(window[6]);
  113.   TextMode(80);
  114. END.
  115.